<template>
  <div class="wrapper">
    <div class="wallet">
      <header>
        <i class="fa fa-angle-left" @click="goBack"></i>
        <p>我的钱包</p>
      </header>
      <div class="box-above">
        <div class="box-above-left">
          <p>钱包</p>
        </div>
        <div class="box-above-right" @click="toDetail">
          <i class="fa fa-list-ul"></i>
          <p>全部明细</p>
        </div>
      </div>
      <div class="fill"></div>
      <div class="box-below">
        <div class="detail">
          <div class="detail-left">
            <div class="detail-head">
              <p>账户余额(元)</p>
              <i class="fa fa-angle-right"></i>
            </div>
            <p>{{ moneyShow |numFilter }}</p>
          </div>
          <div class="detail-right">
            <div class="detail-head">
              <p>赠送金(元)</p>
              <i class="fa fa-angle-right"></i>
            </div>
            <p>0.00</p>
          </div>
        </div>
        <div class="charge" @click="toRecharge">
          <p>充值</p>
        </div>
      </div>
    </div>
  </div>
</template>

<script>
export default {
  name: "Wallet",
  data() {
    return {
      user: {},
      moneyShow: 0
    }
  },
  created() {
    this.user = this.$getSessionStorage('user');
    this.queryWallet();
  },
  filters: {
    numFilter(value) {
      // 截取当前数据到小数点后两位
      let realVal = parseFloat(value).toFixed(2);
      return realVal;
    },
  },
  methods: {
    //跳转到充值页面
    toRecharge() {
      this.$router.push({path: '/recharge'});
    },
    //回退事件
    goBack() {
      this.$router.push({path: '/homepage'});
    },
    //跳转到账单明细
    toDetail() {
      this.$router.push({path: '/walletDetail'});
    },
    queryWallet() {
      //TODO
      this.$axios.get('queryWallet', {
        params: {
          userID: this.user.userId,
        }
      }).then(response => {
        this.moneyShow = response.data;
      }).catch(error => {
        console.error(error);
      });
    }
  }
}
</script>

<style scoped>
.wrapper {
  width: 100%;
  height: 100%;
}

.wrapper .wallet {
  background-image: linear-gradient(to top, rgba(255, 0, 0, 0), rgb(59, 176, 246));
}

.wrapper .wallet header {
  display: flex;
  align-items: center;

  height: 7vw;
  font-weight: 550;
  color: #FFFFFF;

  padding-top: 3vw;
}

.wrapper .wallet header .fa-angle-left {
  margin-left: 3vw;
  font-size: 6vw;
}

.wrapper .wallet header p {
  font-size: 4vw;
  margin-left: 3vw;
}

.wrapper .wallet .box-above {
  display: flex;
  align-items: center;
  justify-content: space-between;

  height: 9vw;

  font-size: 3.5vw;
  color: white;
  background-color: #359cff;
  margin: 2vw 3vw 0 3vw;

  border-radius: 10px 10px 0 0;
  /*border: solid 1px #DDD*/
}

.wrapper .wallet .box-above .box-above-left {
  margin-left: 4vw;
}

.wrapper .wallet .box-above .box-above-left p {
  font-weight: 550;
}

.wrapper .wallet .box-above .box-above-right {
  display: flex;
  align-items: center;

  margin-right: 4vw;
}

.wrapper .wallet .box-above .box-above-right .fa-list-ul {
  margin-right: 2vw;
  font-size: 4vw;
}

.wrapper .wallet .fill {
  height: 5vw;
  border-radius: 0 0 10px 10px;
  background-color: #359cff;
  margin: 0 3vw 0 3vw;
}

.wrapper .wallet .box-below {
  display: flex;
  flex-direction: column;

  height: 35vw;

  font-size: 3vw;
  color: black;
  background-color: #FFFFFF;
  margin: 0 3vw 0 3vw;

  border-radius: 10px;
  border: solid 1px #DDD;
  position: relative;
  bottom: 5vw;
}

.wrapper .wallet .box-below .detail {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex: 5;
}

.wrapper .wallet .box-below .detail p {
  font-size: 5vw;
  font-weight: 700;
}

.wrapper .wallet .box-below .detail .detail-left {
  margin-left: 3vw;
  flex: 1;
  border-right: solid 1px #DDD;
}


.wrapper .wallet .box-below .detail .detail-right {
  flex: 1;
  margin-right: 3vw;
  margin-left: 3vw;
}

.wrapper .wallet .box-below .detail .detail-head {
  display: flex;
  align-items: center;

  margin-bottom: 2vw;
}

.wrapper .wallet .box-below .detail .detail-head .fa-angle-right {
  font-size: 4vw;
  font-weight: 100;
}

.wrapper .wallet .box-below .detail .detail-head p {
  font-size: 3vw;
  font-weight: 200;
  margin-right: 2vw;
  color: rgb(99, 90, 90);
}

.wrapper .wallet .box-below .charge {
  width: 25vw;
  flex: 2;
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 4vw;
  margin-left: 10vw;
  border-radius: 30px;


  color: #ffffff;
  background-color: #359cff;
}
</style>